#!/bin/bash
# Adapting tags in schemas to avoid overriding and/or differentiate between apis
jq '(.paths[][] | select(type=="object")) += {"tags":["financesV0"]}' "./selling-partner-api-models/models/finances-api-model/financesV0.json" > temp && mv temp "./selling-partner-api-models/models/finances-api-model/financesV0.json"
jq '(.paths[][] | select(type=="object")) += {"tags":["financesV2024"]}' "./selling-partner-api-models/models/finances-api-model/finances_2024-06-19.json" > temp && mv temp "./selling-partner-api-models/models/finances-api-model/finances_2024-06-19.json"
jq '(.paths[][] | select(type=="object")) += {"tags":["transfers"]}' "./selling-partner-api-models/models/finances-api-model/transfers_2024-06-01.json" > temp && mv temp "./selling-partner-api-models/models/finances-api-model/transfers_2024-06-01.json"
jq '(.paths[][] | select(type=="object")) += {"tags":["vendorDfOrders"]}' "./selling-partner-api-models/models/vendor-direct-fulfillment-orders-api-model/vendorDirectFulfillmentOrders_2021-12-28.json" > temp && mv temp "./selling-partner-api-models/models/vendor-direct-fulfillment-orders-api-model/vendorDirectFulfillmentOrders_2021-12-28.json"
jq '(.paths[][] | select(type=="object")) += {"tags":["replenishment"]}' "./selling-partner-api-models/models/replenishment-api-model/replenishment-2022-11-07.json" > temp && mv temp "./selling-partner-api-models/models/replenishment-api-model/replenishment-2022-11-07.json"
jq '(.paths[][] | select(type=="object")) += {"tags":["productPricingV2022"]}' "./selling-partner-api-models/models/product-pricing-api-model/productPricing_2022-05-01.json" > temp && mv temp "./selling-partner-api-models/models/product-pricing-api-model/productPricing_2022-05-01.json"
jq '(.paths[][] | select(type=="object")) += {"tags":["vendorDfTransaction"]}' "./selling-partner-api-models/models/vendor-direct-fulfillment-transactions-api-model/vendorDirectFulfillmentTransactions_2021-12-28.json" > temp && mv temp "./selling-partner-api-models/models/vendor-direct-fulfillment-transactions-api-model/vendorDirectFulfillmentTransactions_2021-12-28.json"
jq '(.paths[][] | select(type=="object")) += {"tags":["vendorShipment"]}' "./selling-partner-api-models/models/vendor-shipments-api-model/vendorShipments.json" > temp && mv temp "./selling-partner-api-models/models/vendor-shipments-api-model/vendorShipments.json"
jq '(.paths[][] | select(type=="object")) += {"tags":["fbaInboundV0"]}' "./selling-partner-api-models/models/fulfillment-inbound-api-model/fulfillmentInboundV0.json" > temp && mv temp "./selling-partner-api-models/models/fulfillment-inbound-api-model/fulfillmentInboundV0.json"
jq '(.paths[][] | select(type=="object")) += {"tags":["fbaInboundEligibility"]}' "./selling-partner-api-models/models/fba-inbound-eligibility-api-model/fbaInbound.json" > temp && mv temp "./selling-partner-api-models/models/fba-inbound-eligibility-api-model/fbaInbound.json"
jq '(.paths[][] | select(type=="object")) += {"tags":["listingsRestrictions"]}' "./selling-partner-api-models/models/listings-restrictions-api-model/listingsRestrictions_2021-08-01.json" > temp && mv temp "./selling-partner-api-models/models/listings-restrictions-api-model/listingsRestrictions_2021-08-01.json"
jq '(.paths | .[] | .[] | select(.responses."204") | .responses."204") |= del(.schema)' "./selling-partner-api-models/models/supply-sources-api-model/supplySources_2020-07-01.json" > temp.json && mv temp.json "./selling-partner-api-models/models/supply-sources-api-model/supplySources_2020-07-01.json"
